import Chatlog from "./chatlog"
import Other from "./other"
import store from "../../store"
import { Fragment } from "react"
import Product from "./product"
import Cart from "./cart"
const ChatContainer = () => {
    //获取redux中的状态
    let { status, nickname } = store.getState()

    let handleChangeName = () => {
        store.dispatch({ type: "CHANGE_NAME", payload: "李易峰" })
    }

    //点击退出/登入按钮
    let handleToggle = () => {
        store.dispatch({ type: "CHANGE_STATUS" })
    }

    //使用元素变量声明结构

    let el = (
        <Fragment>
            <h1>用户名:{nickname}</h1>
            <button onClick={handleChangeName}>点击改变名字</button>
            {/* <Product/>
            <Chatlog />
            <Other /> */}
            <Cart/>
        </Fragment>
    )

    return (
        <fieldset>
            <legend>聊天室</legend>

            <button onClick={handleToggle}>点击退出/登入</button>
            {status ? el : null}
        </fieldset>
    )
}

export default ChatContainer